//
//  ProductCommentTableViewCell.m
//  ChunLaiZhuangClient
//
//  Created by xielihui on 16/4/19.
//  Copyright © 2016年 CLZ. All rights reserved.
//

#import "ProductCommentTableViewCell.h"
#import "MyCommentViewController.h"
#import "CommentModel.h"
@interface ProductCommentTableViewCell()
@property (weak, nonatomic) IBOutlet UIImageView *commenterAvatarIV;
@property (weak, nonatomic) IBOutlet UILabel *commenterNameLabel;
@property (weak, nonatomic) IBOutlet UIButton *allCommentBtn;
@property (weak, nonatomic) IBOutlet UILabel *commentContentLabel;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *spaceLineHeightCons;
@end

@implementation ProductCommentTableViewCell

- (void)awakeFromNib {
    // Initialization code
    self.spaceLineHeightCons.constant = .33f;
}

- (void)updateWithComment:(CommentModel *)comment {
    if (comment) {
        [self.commenterAvatarIV sd_setImageWithURL:[NSURL URLWithString:(comment.avatar.length > 0 ? comment.avatar : @"")]];
        self.commenterNameLabel.text = comment.firstname;
        self.commentContentLabel.text = comment.text;
    } else {
        self.commenterNameLabel.hidden = YES;
        self.allCommentBtn.hidden = YES;
        self.commentContentLabel.text = @"暂时还没有评论哦.......";
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    // Configure the view for the selected state
}

- (IBAction)allCommentAction:(id)sender {
    MyCommentViewController *commentVC = [[MyCommentViewController alloc] initWithProductId:[NSString stringWithFormat:@"%@", self.productId]];
    UIViewController *vc = [ProductCommentTableViewCell viewController:self];
    [vc.navigationController pushViewController:commentVC animated:YES];
}
@end
